package com.cdd.goods.controller;


import com.cdd.goods.service.INewgoodsService;
import com.cdd.goods.service.impl.NewgoodsServiceImpl;
import com.common.entity.Goods;
import com.common.entity.GoodsBrand;
import com.common.entity.Newgoods;
import com.common.untils.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lzl
 * @since 2022-09-09
 */
@RestController
@RequestMapping("/goods/newgoods" )
public class NewgoodsController {
    @Autowired
    private INewgoodsService iNewgoodsService;
    @PostMapping("/select/{currentPage}/{pageSize}")
    //public CommonResult select(@PathVariable Integer currentPage, @PathVariable Integer pageSize, @RequestBody Map map){
        public CommonResult select(@PathVariable Integer currentPage, @PathVariable Integer pageSize){

        return  iNewgoodsService.selectAll(currentPage,pageSize);
    }
    //通过按钮
    @PostMapping("/pass")
    public CommonResult pass(@RequestBody Goods goods, HttpServletRequest request){
        //获取token
        String token = request.getHeader("token");
     return iNewgoodsService.pass(goods,token);
    }
    //驳回
    @PostMapping("/reject/{id}")
    public CommonResult reject(@PathVariable String id, @RequestBody  Newgoods newgoods ,HttpServletRequest request){
        //获取token
        String token = request.getHeader("token");
     return iNewgoodsService.reject(id,newgoods,token);
    }
    //商品上新
    @PostMapping("/addNewGoods")
    public CommonResult addNewGoods(@RequestBody Newgoods newgoods){
        return iNewgoodsService.addNewGoods(newgoods);
    }
    //查询审核记录
    @PostMapping("/audit/{currentPage}/{pageSize}")
    public CommonResult audit(@PathVariable Integer currentPage, @PathVariable Integer pageSize,@RequestBody Newgoods newgoods){
        return  iNewgoodsService.audit(currentPage,pageSize,newgoods);
    }


}
